package com.stu.mapper;

import com.stu.pojo.ViolationApplication;
import com.stu.pojo.ViolationInformation;
import com.stu.vo.ViolationApplicationVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ViolationMapper {

    /**
     * 查询处分信息
     *
     * @param currentId
     * @return
     */
    @Select("select * from violation_information where stu_id = #{currentId}")
    List<ViolationInformation> selectViolationInformation(Integer currentId);

    /**
     * 添加处分解除申请
     */
    @Insert("insert into violation_application(stu_id, violation_id, application_time) " +
            "values (#{stuId}, #{violationId}, #{applicationTime})")
    void insertViolationApplication(ViolationApplication violationApplication);

    @Select("select * from violation_application where stu_id = #{currentId}")
    List<ViolationApplication> selectViolationApplication(Long currentId);

    /**
     * 根据id查询
     *
     * @param id
     * @return
     */
    @Select("select * from violation_application where id = #{id}")
    ViolationApplication selectViolationApplicationById(Integer id);

    /**
     * 根据violationId（连接处分信息表的外键）删除 violation_information
     *
     * @param violationId
     */
    @Delete("delete from violation_information where id = #{violationId}")
    void deleteViolation(Integer violationId);

    @Select("select name from stu_basic_information where id = #{currentId}")
    String selectName(Long currentId);

    /**
     * 查询所有处分解除申请
     *
     * @return
     */
    @Select("select * from violation_application")
    List<ViolationApplicationVo> selectViolationApplicationAll();

    void addViolationInformation(ViolationInformation violationInformation);

}
